|
|
![]() | |
|
|
|
To access the contents, click the chapter and section titles.
Fast Track Visual C++ 6.0 Programming
Listing 13.4 Writer2AppView.h and Writer2AppView.cpp
// Writer2AppView.h : interface of the CWriter2AppView class
//
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INCLUDES()
#include writer2.h
//}}AFX_INCLUDES
#if
!defined(AFX_WRITER2APPVIEW_H__2E27A024_AA41_11D1_887F_D42B07C10710__INCLUDED_)
#define AFX_WRITER2APPVIEW_H__2E27A024_AA41_11D1_887F_D42B07C10710__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
class CWriter2AppView : public CFormView
{
protected: // create from serialization only
CWriter2AppView();
DECLARE_DYNCREATE(CWriter2AppView)
public:
//{{AFX_DATA(CWriter2AppView)
enum { IDD = IDD_WRITER2APP_FORM };
CWriter2 m_writer2;
CString m_LengthText;
//}}AFX_DATA
// Attributes
public:
CWriter2AppDoc* GetDocument();
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CWriter2AppView)
public:
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
virtual void OnInitialUpdate(); // called first time after construct
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnPrint(CDC* pDC, CPrintInfo* pInfo);
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CWriter2AppView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
// Generated message map functions
protected:
//{{AFX_MSG(CWriter2AppView)
afx_msg void OnChangeWriter2ctrl1();
afx_msg void OnButton1();
DECLARE_EVENTSINK_MAP()
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#ifndef _DEBUG // debug version in Writer2AppView.cpp
inline CWriter2AppDoc* CWriter2AppView::GetDocument()
{ return (CWriter2AppDoc*)m_pDocument; }
#endif
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately
before the previous line.
#endif //
!defined(AFX_WRITER2APPVIEW_H__2E27A024_AA41_11D1_887F_D42B07C10710__INCLUDED_)
// Writer2AppView.cpp : implementation of the CWriter2AppView class
//
#include stdafx.h
#include Writer2App.h
#include Writer2AppDoc.h
#include Writer2AppView.h
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CWriter2AppView
IMPLEMENT_DYNCREATE(CWriter2AppView, CFormView)
BEGIN_MESSAGE_MAP(CWriter2AppView, CFormView)
//{{AFX_MSG_MAP(CWriter2AppView)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CWriter2AppView construction/destruction
CWriter2AppView::CWriter2AppView()
: CFormView(CWriter2AppView::IDD)
{
//{{AFX_DATA_INIT(CWriter2AppView)
m_LengthText = _T();
//}}AFX_DATA_INIT
// TODO: add construction code here
}
CWriter2AppView::~CWriter2AppView()
{
}
void CWriter2AppView::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CWriter2AppView)
DDX_Control(pDX, IDC_WRITER2CTRL1, m_writer2);
DDX_Text(pDX, IDC_EDIT1, m_LengthText);
//}}AFX_DATA_MAP
}
BOOL CWriter2AppView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
return CFormView::PreCreateWindow(cs);
}
void CWriter2AppView::OnInitialUpdate()
{
CFormView::OnInitialUpdate();
GetParentFrame()->RecalcLayout();
ResizeParentToFit();
}
/////////////////////////////////////////////////////////////////////////////
// CWriter2AppView printing
BOOL CWriter2AppView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CWriter2AppView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CWriter2AppView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
void CWriter2AppView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
// TODO: add code to print the controls
}
/////////////////////////////////////////////////////////////////////////////
// CWriter2AppView diagnostics
#ifdef _DEBUG
void CWriter2AppView::AssertValid() const
{
CFormView::AssertValid();
}
void CWriter2AppView::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
CWriter2AppDoc* CWriter2AppView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CWriter2AppDoc)));
return (CWriter2AppDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CWriter2AppView message handlers
BEGIN_EVENTSINK_MAP(CWriter2AppView, CFormView)
//{{AFX_EVENTSINK_MAP(CWriter2AppView)
ON_EVENT(CWriter2AppView, IDC_WRITER2CTRL1, 1 /* Change */, OnChangeWriter2ctrl1, VTS_NONE)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
void CWriter2AppView::OnChangeWriter2ctrl1()
{
// TODO: Add your control notification handler code here
char text[30];
wsprintf(text, Text length = %d, m_writer2.GetLength() + 1);
m_LengthText = text;
UpdateData(false);
}
void CWriter2AppView::OnButton1()
{ // TODO: Add your control notification handler code here
m_writer2.Clear();
m_LengthText = Text length = 0;
UpdateData(false);
}
Whats AheadIn the next chapter, we explore some professional Windows programming topics: working with the Windows registry and using a programs Version resource. These two programming issuesespecially working with the registryare addressed in most professional applications.
|
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |